﻿#ifndef JISTTABLEVIEW_H
#define JISTTABLEVIEW_H
 #include <QTextEdit>
#include <QTableView>
#include "JistDocument.h"
class JistDocument;
class JistTableView : public QTableView
{
    Q_OBJECT
public:
    enum ChangeStyle
    {
        IMGLIST_CHANGE, // 이미지 바뀜
        SPRITELIST_CHANGE,
        ANIMATIONLIST_CHANGE,
        SCENELIST_CHANGE,
        CELLLIST_CHANGE
    };

    ChangeStyle m_eChangeMode;
    JistDocument *m_pDocument;
    int m_iSelectIndex;
    bool m_isUndoAction;
    bool m_isSelcetChanging;
    QDialog *m_TextEditdialog;
    QTextEdit *m_TextEdit;
    bool m_isDialogBtnOk;

    explicit JistTableView(ChangeStyle ch, QWidget *parent = 0);
    //void currentChanged(const QModelIndex &current, const QModelIndex &previous);
    void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );
    void setDocument(JistDocument *document);
    void mousePressEvent ( QMouseEvent * event );
    void mouseReleaseEvent ( QMouseEvent * event );
    void mouseDoubleClickEvent ( QMouseEvent * event );
    void contextMenuEvent(QContextMenuEvent *event);
    QModelIndexList selectedIndexes () const;
    void refineView(int index);
    void refineViewNoUndo(int index);
    void emitChangeSelectRow(int index);
    void setSelection ( const QRect & rect, QItemSelectionModel::SelectionFlags flags );
    JistCommonData* GetCurrentData();
    void SwapSprite(int currentIdx, int moveIdx);
    void SyncObjectImgIndex(int currentIdx, int moveIdx);

protected:
    virtual void keyPressEvent ( QKeyEvent * event );
public slots:
    void moveItemDown();
    void moveItemUp();
    void copyCellItem();
    void deleteCellItem();
    void copyCellList();
    void deleteCellList();
    void changeSelection(int index);
    void copyAnimation();
    void deleteAnimation();
    void deleteImage();
    void createFakeBmp();
    void setOptCut_WW();
    void setOptCut_WH();
    void setOptCut_NW();
    void setOptCut_NH();
    void setName();
    void setOptCutWider();
    void spriteListRefine();
    void accept();
    void reject();
signals:
    void changeSelectRow(int index);

    void currentCellChanged(JistCommonData*);

private slots:
    void editProperties();
    void editRefProperties();
};

#endif // JISTTABLEVIEW_H
